package chapter12;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @author lzy
 * @create 2018-03-23 下午1:41
 */
public class TcpServer {
    private final static Logger LOGGER = LoggerFactory.getLogger(TcpServer.class);

    public static void main(String[] args) {
        System.out.println("waiting for client connecting...");
        try (ServerSocket server = new ServerSocket(6001);
             Socket socket = server.accept();
             PrintStream out = new PrintStream(socket.getOutputStream())
        ) {
            System.out.println("client is connected...");
            out.print("hello client!");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
